home *** CD-ROM | disk | FTP | other *** search
- //---------------------------------------------------------
- // ext vars
- // @szATCmd - str (LPSTR)
- // @szCID - str
- // @szDCS - str
- // @szDIS - str
- // @szDCC - str
- // @szHNG - str
- // @szNSF - str
- // @lpszRespBuff - str
- // @lPageCnt - long
- // @lPageTotal - long
- // @lSizeForNSF - long
- // @ComIO
- // @GlStr1
- // @GlStr2
- // @RespBuffer
- //---------------------------------------------------------
-
-
- //---------------------------------------------------------
- // ext functions
- //fSetBaudRate(DWORD lpParam, DWORD Baud, DWORD dwN1, DWORD dwN2);
- //fWaitResponse(DWORD lpParam, DWORD lpBuf, DWORD lTimeOut, DWORD dwN1);
- //fSendATCmd(DWORD lpParam, DWORD lpBuf, DWORD dwN1, DWORD dwN2);
- //fSendDLE_ETX(DWORD lpParam, DWORD dwN1, DWORD dwN2, DWORD dwN3);
- //fSleep(DWORD lTime, DWORD dwN1, DWORD dwN2, DWORD dwN3);
- //fFlushRxQueue(DWORD lpParam, DWORD dwN1, DWORD dwN2, DWORD dwN3);
- //fFlushTxQueue(DWORD lpParam, DWORD dwN1, DWORD dwN2, DWORD dwN3);
- //fSendOneChar(DWORD lpParam, DWORD dwCh, DWORD dwN1, DWORD dwN2);
- //fWaitOneChar(DWORD lpParam, DWORD lpResultChar, DWORD lTimeOut, DWORD dwN1);
- //fSetDTR(DWORD lpParam, DWORD dwN1, DWORD dwN2, DWORD dwN3);
- //fResetDTR(DWORD lpParam, DWORD dwN1, DWORD dwN2, DWORD dwN3);
- //fSetRTS(DWORD lpParam, DWORD dwN1, DWORD dwN2, DWORD dwN3);
- //fResetRTS(DWORD lpParam, DWORD dwN1, DWORD dwN2, DWORD dwN3);
- //fSetMisc(DWORD lpParam, DWORD nParity, DWORD nDataBits, DWORD nStopBits);
- //fSetMiscMore(DWORD lpParam, DWORD bDTRDSR, DWORD bRTSCTS, DWORD bXONXOFF);
- //fHardFlowControl(DWORD lpParam, DWORD Type, DWORD dwN1, DWORD dwN2);
- //fSoftFlowControl(DWORD lpParam, DWORD Type, DWORD dwN1, DWORD dwN2);
- //fSkipSpaceStrStr(DWORD s1, DWORD s2, DWORD dwN1, DWORD dwN2);
- //fTxFirstResponseError(DWORD s1, DWORD s2, DWORD dwN1, DWORD dwN2);
- //
- // For fHardFlowControl:
- // param1 - 0000X0YY X - Cts flow control
- // YY : 00 - RTS DISABLE
- // YY : 01 - RTS ENABLE
- // YY : 10 - RTS HANDSHAKE
- // YY : 11 - RTS TOGGLE
- //---------------------------------------------------------
-
- //
- // This is the script file for Class2.
- //
- // trace
- declare STRING %szStr1, %szStr2;
- declare STRING %szStr3, %szStr4;
- declare STRING %szPass1, %szPass2;
- declare STRING %szPass3, %szPass4;
- declare STRING %szMsg1;
- declare long %lRes;
- declare long %lRes1;
- declare long %lTemp;
- declare long %lGRes;
- declare long %lMsg1;
- declare char %XON;
- declare STRING %szNULL;
-
- //----------------------------------------------------------------------
- // SubSendCmdWaitResp
- //----------------------------------------------------------------------
- sub SubSendCmdWaitResp(STRING #szCmd, STRING #szResp, long #lWaitTime)
- declare long %lRes;
- declare STRING %szCheckAT;
- declare long %lLimit;
-
- %lLimit = 0
- %szCheckAT = "AT"
- %lRes = fSkipSpaceStrStr(%szCheckAT, #szCmd)
- if (%lRes = 0)
- {
- %lRes = 0
- goto SendCmd1
- }
-
- %lRes = fSendATCmd(@ComIO, #szCmd)
- if (%lRes!=0)
- {
- %lRes = 101
- goto SendCmd1
- }
-
- :SendCmd0
- %lRes = fWaitResponse(@ComIO, #lWaitTime)
- if (%lRes != 0)
- {
- %lRes = 101
- goto SendCmd1
- }
-
- %lRes = fSkipSpaceStrStr(#szResp, @RespBuffer)
- if (%lRes != 0)
- {
- %lRes = 0
- goto SendCmd1
- }
-
- // some response but doesnt match, retry agian if necessary
- %lLimit = %lLimit+1
- if (%lLimit < 3)
- goto SendCmd0
-
- // Not match...
- %lRes = 101
-
- :SendCmd1
- %lGRes = %lRes
- endsub
-
- //----------------------------------------------------------------------
- // For Dialing number
- //----------------------------------------------------------------------
- :TX_DIAL
- fFlushRxQueue(@ComIO)
- fSendATCmd(@ComIO, @szATCmd)
- fFlushRxQueue(@ComIO)
- exit(0)
-
-
-
- //----------------------------------------------------------------------
- // For TX initialization part 1
- //
- // and for fHardFlowControl(@ComIO, 9) - CTS on / RTS on
- //----------------------------------------------------------------------
- :TX_INIT1
- fHardFlowControl(@ComIO, 9)
- fSetBaudRate(@ComIO, 19200)
- fFlushRxQueue(@ComIO)
- fFlushTxQueue(@ComIO)
- @szATCmd = "ATS0=0M0E0"
- fSendATCmd(@ComIO, @szATCmd)
- fSleep(500)
- fFlushRxQueue(@ComIO)
- @szATCmd = "ATS0=0M0E0"
- fSendATCmd(@ComIO, @szATCmd)
- fSleep(500)
- fFlushRxQueue(@ComIO)
-
- call SubSendCmdWaitResp("ATS0=0", "OK", 3000)
- fSleep(150)
-
- call SubSendCmdWaitResp("ATE0V1&C1", "OK", 3000)
- fSleep(150)
-
- // call SubSendCmdWaitResp(@szATCmd, "OK", 3000)
-
- %lRes1 = %lGRes
- call SubSendCmdWaitResp("AT&K3", "OK", 3000)
- // call SubSendCmdWaitResp("AT&K4", "OK", 3000)
- %lGRes = %lRes1
- fSleep(150)
-
- exit (%lGRes)
-
- :TX_INIT2
- call SubSendCmdWaitResp("AT+FCLASS=2", "OK", 3000)
- fSleep(150)
-
- if (%lGRes = 0)
- fSetBaudRate(@ComIO, 19200)
- exit (%lGRes)
-
- :TX_INIT3
- %szStr1 = "AT+FLID="
- %szStr2 = %szStr1 + @szCID
- call SubSendCmdWaitResp(%szStr2, "OK", 3000)
- fSleep(150)
- if (%lGRes!=0)
- exit (%lGRes)
-
- %szStr1 = "AT+FDIS="
- %szStr2 = %szStr1 + @szDCC
- call SubSendCmdWaitResp(%szStr2, "OK", 3000)
- fSleep(150)
- if (%lGRes!=0)
- exit (%lGRes)
-
- %szStr2 = "AT+FAA=0"
- call SubSendCmdWaitResp(%szStr2, "OK", 3000)
- fSleep(150)
- if (%lGRes!=0)
- exit (%lGRes)
-
- fFlushRxQueue(@ComIO)
- %szStr2 = "AT+FBOR=0"
- call SubSendCmdWaitResp(%szStr2, "OK", 3000)
- fSleep(150)
- if (%lGRes!=0)
- exit (%lGRes)
-
-
- //
- // You can do all kind of thing here...
- :TX_INIT4
- exit (0)
-
-
- //----------------------------------------------------------------------
- // Now we go to Tx phase B - Wait for OK and send AT+FDR
- //
- // ??? I dont know whether we need to wait for FCON or not...
- //----------------------------------------------------------------------
- :TXPH_B_START
- %szStr3 = "This is in TXPH_B_START"
- %lRes = fPrintMsg(%szStr3)
-
- :TXPH_B_START1
- %lRes = fWaitResponse(@ComIO, 5000)
- if (%lRes != 0)
- exit (4)
-
- // Check to see if any error happens. eg: No dial tone, busy...
- %lRes = fTxFirstResponseError(@RespBuffer)
- if (%lRes != 0)
- {
- exit (%lRes)
- }
-
- // Yes, sth is the buffer, we need to compare it
- %szStr3 = "OK"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- {
- %szStr3 = "AT+FDT"
- fSendATCmd(@ComIO, %szStr3)
- exit (0) // OK
- }
-
- %szStr3 = "+FNSF"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- {
- @szNSF = @RespBuffer
- goto TXPH_B_START1
- }
-
- %szStr3 = "+FCSI"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- {
- @szCID = @RespBuffer
- goto TXPH_B_START1
- }
-
- %szStr3 = "+FDIS"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- {
- @szDIS = @RespBuffer
- goto TXPH_B_START1
- }
-
- // The rest of them go back to start...
- goto TXPH_B_START1
-
- //----------------------------------------------------------------------
- // Tx Wait for training - Wait for CONNECT and XON
- //----------------------------------------------------------------------
- :TXTRAIN_START
- %szStr3 = "This is in TXTRAIN_START"
- %lRes = fPrintMsg(%szStr3)
-
- :TXTRAIN_START1
- %lRes = fWaitResponse(@ComIO, 20000)
- if (%lRes != 0)
- exit (1)
-
- // Check for FDCS
- %szStr3 = "FDCS"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- {
- @szDCS = @RespBuffer
- }
-
- if (%lRes != 0)
- goto TXTRAIN_START1
-
- // Yes, sth is the buffer, we need to compare it
- %szStr3 = "CONNECT"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- exit (0)
- else
- goto TXTRAIN_START1
-
-
- //----------------------------------------------------------------------
- //----------------------------------------------------------------------
- :TXPH_C_START
- fSoftFlowControl(@ComIO, 1)
- exit (0)
-
-
- //----------------------------------------------------------------------
- // TX Phase D
- // 1) Wait for OK
- // 2) Send AT+FET=0/2
- // 3) Wait for +FPTS/+FHNG
- // 4) Wait for OK
- // 5) Send AT+FDT if necessary
- // 6) Wait for CONNECT and XON if necessary
- //----------------------------------------------------------------------
- :TXPH_D_START
- %szStr3 = "This is in TXPH_D_START"
- %lRes = fPrintMsg(%szStr3)
- fFlushRxQueue(@ComIO)
- fSendDLE_ETX(@ComIO)
-
- :TXPH_D0
- %lRes = fWaitResponse(@ComIO, 25000)
-
- // NO response error (3)
- if (%lRes != 0)
- exit (3)
-
-
- // Some dumb modem, even in no-echo mode, will still echo AT+FDT
- %szStr3 = "AT+FDT"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- goto TXPH_D0
-
-
- %szStr3 = "OK"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes = 0)
- goto TXPH_D0
-
- %lRes = @lPageCnt + 1
- @lPageCnt = %lRes
-
- if (@lPageCnt >= @lPageTotal)
- {
- %lTemp = 0
- @szATCmd = "AT+FET=2"
- fSendATCmd(@ComIO, @szATCmd)
- }
- else
- {
- %lTemp = 1
- @szATCmd = "AT+FET=0"
- fSendATCmd(@ComIO, @szATCmd)
- }
-
- :TXPH_D1
- %lRes = fWaitResponse(@ComIO, 20000)
- if (%lRes != 0)
- exit (3)
-
- // Check to see if get the +FHNG signal...
- %szStr3 = "FHNG"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- {
- @szHNG = @RespBuffer
- exit (0)
- }
-
- //----------------------------------------------------------
- // Check for bad page response... NOTE A. (Only FPTS:1 is good)
- //----------------------------------------------------------
- %szStr3 = "FPTS:0"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- exit (3)
-
- %szStr3 = "FPTS:2"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- exit (3)
-
- %szStr3 = "FPTS:3"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- exit (3)
-
- %szStr3 = "FPTS:4"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- exit (3)
-
- %szStr3 = "FPTS:5"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- exit (3)
-
- %szStr3 = "FPTS:6"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- exit (3)
-
- %szStr3 = "FPTS:7"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- exit (3)
-
- //----------------------------------------------------------
- // End of check bad page. See NOTE A above
- //----------------------------------------------------------
-
- %szStr3 = "OK"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- goto TXPH_D2
- goto TXPH_D1
-
- //
- // Send AT+FDT and wait for connect
- //
- :TXPH_D2
- %szStr3 = "AT+FDT"
- fSendATCmd(@ComIO, %szStr3)
-
- :TXPH_D3
- %lRes = fWaitResponse(@ComIO, 20000)
- if (%lRes != 0)
- exit (3)
-
- // Yes, sth is the buffer, we need to compare it
- %szStr3 = "CONNECT"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- exit (1)
- else
- goto TXPH_D3
-
- //----------------------------------------------------------------------
- // TX Disconnecting the line
- //----------------------------------------------------------------------
- :ABORT1
- :TX_DISC1
- %szStr3 = "This is in TX_DISC1"
- %lRes = fPrintMsg(%szStr3)
-
- fFlushRxQueue(@ComIO)
- fSendDLE_ETX(@ComIO)
- %szStr3 = "AT"
- fSendATCmd(@ComIO, %szStr3)
- fSleep(1000)
- %szStr3 = "AT"
- fSendATCmd(@ComIO, %szStr3)
- fSleep(1000)
- fFlushRxQueue(@ComIO)
- fFlushTxQueue(@ComIO)
- %szStr3 = "AT+FCLASS=0"
- fSendATCmd(@ComIO, %szStr3)
- fSleep(1000)
- fSetBaudRate(@ComIO, 2400)
- fSleep(200)
- %szStr3 = "ATH0"
- fSendATCmd(@ComIO, %szStr3)
- fSleep(200)
- fFlushRxQueue(@ComIO)
- fSendATCmd(@ComIO, @szATCmd) // comes from szTxQuitString
- fSleep(500)
- fResetDTR(@ComIO)
- fSleep(1000)
- fSetDTR(@ComIO)
- fFlushRxQueue(@ComIO)
- fFlushTxQueue(@ComIO)
- exit (0)
-
- :ABORT2
- :TX_DISC2
- fFlushRxQueue(@ComIO)
- fFlushTxQueue(@ComIO)
- fSendATCmd(@ComIO, @szATCmd)
- fSleep(1000)
- fFlushRxQueue(@ComIO)
- fFlushTxQueue(@ComIO)
- exit (0)
-
- :TX_DISC3
- exit (0)
-
- :TX_DISC4
- exit (0)
-
- //----------------------------------------------------------------------
- // The following are for RX fax
- //----------------------------------------------------------------------
- //----------------------------------------------------------------------
- // For HardFlowControl - use 11 means CTS on/RTS toggle.
- //----------------------------------------------------------------------
- :RX_INIT1
- fHardFlowControl(@ComIO, 9)
- fSoftFlowControl(@ComIO, 0)
- fSetBaudRate(@ComIO, 19200)
- fFlushRxQueue(@ComIO)
- fFlushTxQueue(@ComIO)
- @szATCmd = "ATS0=0M0E0"
- fSendATCmd(@ComIO, @szATCmd)
- fSleep(500)
- fFlushRxQueue(@ComIO)
- @szATCmd = "ATS0=0M0E0"
- fSendATCmd(@ComIO, @szATCmd)
- fSleep(500)
- fFlushRxQueue(@ComIO)
- call SubSendCmdWaitResp("ATS0=0", "OK", 3000)
- fSleep(150)
- call SubSendCmdWaitResp("AT&FE0V1&C1&D2", "OK", 3000)
- fSleep(150)
- exit (%lGRes)
-
- :RX_INIT2
- call SubSendCmdWaitResp("AT+FCLASS=2", "OK", 3000)
- fSleep(150)
- if (%lGRes = 0)
- fSetBaudRate(@ComIO, 19200)
- exit (%lGRes)
-
- :RX_INIT3
- %szStr1 = "AT+FLID="
- %szStr2 = %szStr1 + @szCID
- call SubSendCmdWaitResp(%szStr2, "OK", 3000)
- fSleep(150)
- if (%lGRes!=0)
- exit (%lGRes)
-
- %szStr1 = "AT+FDIS="
- %szStr2 = %szStr1 + @szDCC
- call SubSendCmdWaitResp(%szStr2, "OK", 3000)
- fSleep(150)
- if (%lGRes!=0)
- exit (%lGRes)
-
- %szStr2 = "AT+FAA=0"
- call SubSendCmdWaitResp(%szStr2, "OK", 3000)
- fSleep(150)
- if (%lGRes!=0)
- exit (%lGRes)
-
- %szStr2 = "AT+FBOR=1"
- call SubSendCmdWaitResp(%szStr2, "OK", 3000)
- fSleep(150)
- if (%lGRes!=0)
- exit (%lGRes)
-
-
- %szStr2 = "AT+FCR=1"
- call SubSendCmdWaitResp(%szStr2, "OK", 3000)
- fSleep(150)
- if (%lGRes!=0)
- exit (%lGRes)
-
- :RX_INIT4
- exit (0)
-
-
- //----------------------------------------------------------------------
- // RX_WAITCALL
- //
- // Wait for 3 seconds for RING signal
- //----------------------------------------------------------------------
- :RX_WAITCALL
- %szStr3 = "This is in RX_WAITCALL (C2)"
- %lRes = fPrintMsg(%szStr3)
-
- fFlushRxQueue(@ComIO)
- fFlushTxQueue(@ComIO)
- %lRes = fWaitResponse(@ComIO, 3000)
- if (%lRes != 0)
- exit (%lRes)
-
- // Something is in the buffer, check if this is RING signal
- %szStr3 = "RING"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- exit (0)
- else
- exit (1)
-
-
- //----------------------------------------------------------------------
- // RX_ANSWERCALL
- //----------------------------------------------------------------------
- :RX_ANSWERCALL
- %szStr3 = "This is in RX_ANSWERCALL"
- %lRes = fPrintMsg(%szStr3)
-
- fFlushRxQueue(@ComIO)
- fFlushTxQueue(@ComIO)
-
- @lPageTotal = 0
- @lPageCnt = 0
-
- call SubSendCmdWaitResp("AT+FCLASS=2", "OK", 3000)
- fSleep(150)
- if (%lGRes = 0)
- fSetBaudRate(@ComIO, 19200)
-
-
- fFlushRxQueue(@ComIO)
- @szATCmd = "ATA"
- fSendATCmd(@ComIO, @szATCmd)
- exit (0)
-
- //----------------------------------------------------------------------
- // RX_PH_B_START
- //----------------------------------------------------------------------
- :RXPH_B_START
- %szStr3 = "This is in RXPH_B_START"
- %lRes = fPrintMsg(%szStr3)
-
- %lRes = fWaitResponse(@ComIO, 30000)
- if (%lRes != 0)
- exit (1)
-
- // Check to see if any error happens. eg: No dial tone, busy...
- %lRes = fPrintMsg(@RespBuffer)
-
-
- %lRes = fTxFirstResponseError(@RespBuffer)
- if (%lRes != 0)
- {
- exit (%lRes)
- }
-
- // Yes, sth is the buffer, we need to compare it
- %szStr3 = "OK"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- {
- %szStr3 = "AT+FDR"
- fSendATCmd(@ComIO, %szStr3)
- exit (0) // OK
- }
-
- %szStr3 = "+FNSS"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- {
- @szNSF = @RespBuffer
- goto RXPH_B_START
- }
-
- %szStr3 = "+FTSI"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- {
- @szCID = @RespBuffer
- goto RXPH_B_START
- }
-
- %szStr3 = "+FDCS"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- {
- @szDCS = @RespBuffer
- goto RXPH_B_START
- }
-
- // The rest of them go back to start...
- goto RXPH_B_START
-
-
-
- //----------------------------------------------------------------------
- // Rx Wait for training - Wait for CONNECT and XON
- //----------------------------------------------------------------------
- :RXTRAIN_START
- %szStr3 = "This is in RXTRAIN_START"
- %lRes = fPrintMsg(%szStr3)
-
-
- %lRes = fWaitResponse(@ComIO, 20000)
- if (%lRes != 0)
- exit (1)
-
- // Check for FDCS
- %szStr3 = "FDCS"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- {
- @szDCS = @RespBuffer
- }
-
- if (%lRes != 0)
- goto RXTRAIN_START
-
- // Yes, sth is the buffer, we need to compare it
- %szStr3 = "CONNECT"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- exit (0)
- else
- goto RXTRAIN_START
-
-
-
- //----------------------------------------------------------------------
- // RX Phase D
- //
- // exit (3) - error
- // (0) - No more page to receive
- // (1) - more page to receive - go to phase C
- // (2) - more page to receive - BUT go to phase B
- //----------------------------------------------------------------------
- :RXPH_D_START
- %szStr3 = "This is in RXPH_D_START"
- %lRes = fPrintMsg(%szStr3)
-
-
- %lTemp = 0
- %lRes = @lPageTotal + 1
- @lPageTotal = %lRes
-
- %lRes = @lPageCnt + 1
- @lPageCnt = %lRes
-
-
- :RXPH_D0
- %lRes = fWaitResponse(@ComIO, 25000)
-
- // NO response error (3)
- if (%lRes != 0)
- exit (3)
-
- %szStr3 = "FET:0"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- %lTemp = 1
-
- if (%lRes != 0)
- goto RXPH_D1
-
-
- %szStr3 = "FET:2"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- goto RXPH_D1
-
- %szStr3 = "ERROR"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- exit (3)
-
- %szStr3 = "FHNG"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- {
- @szHNG = @RespBuffer
- exit (3)
- }
-
- goto RXPH_D0
-
- :RXPH_D1
- %szStr3 = "This is in RXPH_D1_111"
- %lRes = fPrintMsg(%szStr3)
-
- %lRes = fWaitResponse(@ComIO, 20000)
- if (%lRes != 0)
- exit (3)
-
- // Check to see if get the +FHNG signal...
- %szStr3 = "FHNG"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- {
- @szHNG = @RespBuffer
- exit (0)
- }
-
- %szStr3 = "OK"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- goto RXPH_D2
- goto RXPH_D1
-
- //
- // Send AT+FDT and wait for connect
- //
- :RXPH_D2
- %szStr3 = "This is in RXPH_D2_111"
- %lRes = fPrintMsg(%szStr3)
-
- %szStr3 = "AT+FDR"
- fSendATCmd(@ComIO, %szStr3)
-
- :RXPH_D3
- %lRes = fWaitResponse(@ComIO, 20000)
- if (%lRes != 0)
- exit (3)
-
- // Some dumb modem, even in no-echo mode, will still echo AT+FDR
- %szStr3 = "AT+FDR"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- goto RXPH_D3
-
-
-
- // Yes, sth is the buffer, we need to compare it.
- %szStr3 = "CONNECT"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- exit (1) // more page to receive - go to phase C
-
- %szStr3 = "FHNG"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- {
- @szHNG = @RespBuffer
- exit (0)
- }
-
- %szStr3 = "OK"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- exit (0)
-
- %szStr3 = "ERROR"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- exit (3)
-
-
- //----------------------------------------------------------------------
- //
- //----------------------------------------------------------------------
- :RX_DISC1
- %szStr3 = "This is in RX_DISC1"
- %lRes = fPrintMsg(%szStr3)
-
- fFlushRxQueue(@ComIO)
- fSendDLE_ETX(@ComIO)
- %szStr3 = "AT"
- fSendATCmd(@ComIO, %szStr3)
- fSleep(1000)
- %szStr3 = "AT"
- fSendATCmd(@ComIO, %szStr3)
- fSleep(1000)
- fFlushRxQueue(@ComIO)
- fFlushTxQueue(@ComIO)
- %szStr3 = "AT+FCLASS=0"
- fSendATCmd(@ComIO, %szStr3)
- fSleep(1000)
- fSetBaudRate(@ComIO, 2400)
- fSleep(200)
- %szStr3 = "ATH0"
- fSendATCmd(@ComIO, %szStr3)
- fSleep(200)
- fFlushRxQueue(@ComIO)
- fSendATCmd(@ComIO, @szATCmd) // comes from szTxQuitString
- fSleep(500)
- fResetDTR(@ComIO)
- fSleep(1000)
- fSetDTR(@ComIO)
- fFlushRxQueue(@ComIO)
- fFlushTxQueue(@ComIO)
- exit (0)
-
- :RX_DISC2
- fFlushRxQueue(@ComIO)
- fFlushTxQueue(@ComIO)
- fSendATCmd(@ComIO, @szATCmd)
- fSleep(1000)
- fFlushRxQueue(@ComIO)
- fFlushTxQueue(@ComIO)
- exit (0)
-
- :RX_DISC3
- exit (0)
-
- :RX_DISC4
- exit (0)
-
-
- //----------------------------------------------------------------------
- //----------------------------------------------------------------------
- :TAPIRX_INIT1
- %szStr3 = "This is in TAPIRX_INIT"
- %lRes = fPrintMsg(%szStr3)
-
- fSendOneChar(@ComIO, 16)
- fSendOneChar(@ComIO, 3)
- fSendOneChar(@ComIO, 16)
- fSendOneChar(@ComIO, 3)
-
- fSendOneChar(@ComIO, 16)
- fSendOneChar(@ComIO, 24)
- call SubSendCmdWaitResp("AT", "OK", 1000)
- fSleep(150)
- call SubSendCmdWaitResp("ATE0V1", "OK", 1000)
- fSleep(150)
- fHardFlowControl(@ComIO, 9)
- fSoftFlowControl(@ComIO, 0)
- fSetBaudRate(@ComIO, 19200)
- fFlushRxQueue(@ComIO)
- fFlushTxQueue(@ComIO)
-
-
- call SubSendCmdWaitResp("AT#CLS=0", "OK", 1000)
- fSleep(500)
- call SubSendCmdWaitResp("AT#BDR=0", "OK", 1000)
- fSleep(150)
- call SubSendCmdWaitResp("ATE0V1&C1&D2", "OK", 1000)
- fSleep(150)
- call SubSendCmdWaitResp("AT+FCLASS=2", "OK", 1000)
- fSleep(150)
- fSetBaudRate(@ComIO, 19200)
- call SubSendCmdWaitResp("AT+FAA=0", "OK", 1000)
- fSleep(150)
- call SubSendCmdWaitResp("AT+FBOR=1", "OK", 1000)
- fSleep(150)
- call SubSendCmdWaitResp("AT+FCR=1", "OK", 1000)
- fSleep(150)
-
- %szStr1 = "AT+FLID="
- %szStr2 = %szStr1 + @szCID
- call SubSendCmdWaitResp(%szStr2, "OK", 3000)
- fSleep(150)
- if (%lGRes!=0)
- exit (%lGRes)
-
- %szStr1 = "AT+FDIS="
- %szStr2 = %szStr1 + @szDCC
- call SubSendCmdWaitResp(%szStr2, "OK", 3000)
- fSleep(150)
- if (%lGRes!=0)
- exit (%lGRes)
-
- fFlushRxQueue(@ComIO)
- fFlushTxQueue(@ComIO)
- @szATCmd = "ATA"
- fSendATCmd(@ComIO, @szATCmd)
- exit (0)
-
- :TAPIRX_INIT2
- exit (0)
-
- :TAPIRX_INIT3
- exit (0)
-
-
- //----------------------------------------------------------------------
- //----------------------------------------------------------------------
- :TAPITX_INIT1
- fHardFlowControl(@ComIO, 9)
- fFlushRxQueue(@ComIO)
- // call SubSendCmdWaitResp("ATE0V1&C1", "OK", 3000)
- call SubSendCmdWaitResp("AT+FCLASS=2", "OK", 3000)
- fSleep(150)
- fSetBaudRate(@ComIO, 19200)
-
- // %szStr1 = "AT+FLID="
- // %szStr2 = %szStr1 + @szCID
- // call SubSendCmdWaitResp(%szStr2, "OK", 3000)
-
- // %szStr1 = "AT+FDIS="
- // %szStr2 = %szStr1 + @szDCC
- // call SubSendCmdWaitResp(%szStr2, "OK", 3000)
-
- @szATCmd = "ATD"
- fSendATCmd(@ComIO, @szATCmd)
- exit (0)
-
- :TAPITX_INIT2
- exit (0)
-
- :TAPITX_INIT3
- exit (0)
-
-
-
-